using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace MagicFight
{
    /// <summary>
    /// Classe baseada no Not So Healthy.
    /// </summary>
    public class Bar
    {
        public Texture2D bar;
        public Color bgColor = Color.Gray;

        public Bar(Texture2D sprite)
        {
            bar = sprite;
        }

        public void Draw(SpriteBatch spriteBatch, float mCurrentHealth, Vector2 pos, Color color)
        {
            Draw(spriteBatch, mCurrentHealth, pos, color, 1, true);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="mCurrentHealth">Quantidade entre 0 e 1.</param>
        /// <param name="pos"></param>
        public void Draw(SpriteBatch spriteBatch, float mCurrentHealth, Vector2 pos, Color color, float scale, bool isVertical)
        {
            mCurrentHealth = MathHelper.Clamp(mCurrentHealth, 0, 1);

            Vector2 origin = new Vector2(bar.Width / 2, bar.Height / 2);

            //Draw the negative space for the health bar
            spriteBatch.Draw(bar, pos, null, bgColor, (isVertical ? -(float)Math.PI / 2 : 0), origin, scale, SpriteEffects.None, 0);

            //Draw the current health level based on the current Health
            spriteBatch.Draw(bar, pos, new Rectangle(0, 0, (int)(bar.Width * mCurrentHealth), bar.Height), color, (isVertical ? -(float)Math.PI / 2 : 0), origin, scale, SpriteEffects.None, 0);

            //Draw the box around the health bar
            //spriteBatch.Draw(bar, pos, new Rectangle(0, 0, bar.Width, 44), Color.White, 0, new Vector2(bar.Width / 2, 22), .1f, SpriteEffects.None, 0);

        }
    }
}